package com.ak.game.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@EnableAsync
public class AsyncConfig {
    @Bean
    public ThreadPoolTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor gameExecutor = new ThreadPoolTaskExecutor();
        gameExecutor.setCorePoolSize(10); // 核心线程数
        gameExecutor.setMaxPoolSize(100); // 最大线程数
        gameExecutor.setQueueCapacity(10000); // 队列容量
        gameExecutor.setThreadNamePrefix("BettingExecutor-"); // 线程前缀
        gameExecutor.initialize();
        return gameExecutor;
    }
}
